package rad.framework.mda.generator.template.main.webapp;

import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.*;
import java.util.*;
import rad.framework.mda.generator.util.*;

public class DetailCells
{
  protected static String nl;
  public static synchronized DetailCells create(String lineSeparator)
  {
    nl = lineSeparator;
    DetailCells result = new DetailCells();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<ui:composition " + NL + "\txmlns:ui=\"http://java.sun.com/jsf/facelets\"" + NL + "\txmlns:s=\"http://jboss.com/products/seam/taglib\"" + NL + "\txmlns:p=\"http://jboss.com/products/seam/pdf\"" + NL + "\txmlns:tt=\"https://code.google.com/p/rad-framework/pdf\">" + NL + "" + NL + "\t<tt:attributes>";
  protected final String TEXT_2 = NL;
  protected final String TEXT_3 = NL + "\t<ui:remove>";
  protected final String TEXT_4 = NL + "\t\t<tt:attribute type=\"";
  protected final String TEXT_5 = "\" id=\"";
  protected final String TEXT_6 = "\" " + NL + "\t\t\tvalue=\"#{entity.";
  protected final String TEXT_7 = "}\"" + NL + "\t\t\tlabel=\"#{messages['";
  protected final String TEXT_8 = "_";
  protected final String TEXT_9 = "']}\"\t/>";
  protected final String TEXT_10 = NL + "\t</ui:remove>";
  protected final String TEXT_11 = NL + NL + "\t</tt:attributes>" + NL + "\t";
  protected final String TEXT_12 = NL + "\t<p:paragraph alignment=\"left\" spacingBefore=\"10\" spacingAfter=\"20\">" + NL + "\t\t<p:html>" + NL + "\t\t\t<s:formattedText  value=\"#{entity.";
  protected final String TEXT_13 = "}\"/>" + NL + "\t\t</p:html>\t" + NL + "\t</p:paragraph>";
  protected final String TEXT_14 = NL + "\t";
  protected final String TEXT_15 = NL + NL + "\t<tt:reference type=\"";
  protected final String TEXT_16 = "\" id=\"";
  protected final String TEXT_17 = "\" " + NL + "\t\tvalue=\"#{entity.";
  protected final String TEXT_18 = "}\"" + NL + "\t\tlabel=\"#{messages['";
  protected final String TEXT_19 = "_";
  protected final String TEXT_20 = "']}\"\t/>";
  protected final String TEXT_21 = NL + NL + "\t<tt:reference type=\"";
  protected final String TEXT_22 = "\" id=\"";
  protected final String TEXT_23 = "\" " + NL + "\t\tvalue=\"#{entity.";
  protected final String TEXT_24 = "}\"" + NL + "\t\tlabel=\"#{messages['";
  protected final String TEXT_25 = "_";
  protected final String TEXT_26 = "']}\"\t/>";
  protected final String TEXT_27 = NL + NL + "</ui:composition>";
  protected final String TEXT_28 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
Class uml2Class = (Class) argument;

    stringBuffer.append(TEXT_1);
    for (Iterator<Property> i=ClassHelper.getAllSimpleProperties(uml2Class); i.hasNext();) { Property property = i.next();
    if (!TypeHelper.isText(property)) {
    stringBuffer.append(TEXT_2);
    if (StereotypeHelper.isStereotypeApplied(property, StereotypeHelper.GENERATED_VALUE)) {
    stringBuffer.append(TEXT_3);
    }
    stringBuffer.append(TEXT_4);
    stringBuffer.append(JsfHelper.getType(property));
    stringBuffer.append(TEXT_5);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_6);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(uml2Class.getName());
    stringBuffer.append(TEXT_8);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_9);
    if (StereotypeHelper.isStereotypeApplied(property, StereotypeHelper.GENERATED_VALUE)) {
    stringBuffer.append(TEXT_10);
    }}}
    stringBuffer.append(TEXT_11);
    for (Iterator<Property> i=ClassHelper.getAllSimpleProperties(uml2Class); i.hasNext();) { Property property = i.next();
    if (TypeHelper.isText(property)) {
    stringBuffer.append(TEXT_12);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_13);
    }}
    stringBuffer.append(TEXT_14);
    for (Iterator<Property> i=ClassHelper.getAllManyToOneProperties(uml2Class); i.hasNext();) { Property property = i.next();
    if (StereotypeHelper.isStereotypeApplied(property, StereotypeHelper.M2O) && property.getOpposite() == null) {
    stringBuffer.append(TEXT_15);
    stringBuffer.append(NameHelper.getCapName(property.getType()));
    stringBuffer.append(TEXT_16);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_17);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_18);
    stringBuffer.append(uml2Class.getName());
    stringBuffer.append(TEXT_19);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_20);
    }}
    for (Iterator<Property> i=ClassHelper.getCompositeProperties(uml2Class); i.hasNext();) { Property property = i.next();
    stringBuffer.append(TEXT_21);
    stringBuffer.append(NameHelper.getCapName(property.getType()));
    stringBuffer.append(TEXT_22);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_23);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_24);
    stringBuffer.append(uml2Class.getName());
    stringBuffer.append(TEXT_25);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_26);
    }
    stringBuffer.append(TEXT_27);
    stringBuffer.append(TEXT_28);
    return stringBuffer.toString();
  }
}
